package com.kb.erp.service.digi;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

// Root class


@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class ProductData {

    @JsonProperty("Product")
    private Product product;

//    @JsonProperty("Product")
//    private Product product;




    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Product {

        @JsonProperty("Parameters")
        private List<Parameters> parameters;

        @JsonProperty("Description")
        private Description description;

        @JsonProperty("Manufacturer")
        private Manufacturer manufacturer;

        @JsonProperty("ManufacturerProductNumber")
        private String manufacturerProductNumber;

        @JsonProperty("UnitPrice")
        private double unitPrice;

        @JsonProperty("ProductUrl")
        private String productUrl;

        @JsonProperty("DatasheetUrl")
        private String datasheetUrl;

        @JsonProperty("PhotoUrl")
        private String photoUrl;

        @JsonProperty("ProductVariations")
        private List<ProductVariation> productVariations;

        @JsonProperty("QuantityAvailable")
        private int quantityAvailable;

        @JsonProperty("ProductStatus")
        private StatusEntity productStatus;

        @JsonProperty("BackOrderNotAllowed")
        private boolean backOrderNotAllowed;

        @JsonProperty("NormallyStocking")
        private boolean normallyStocking;

        @JsonProperty("Discontinued")
        private boolean discontinued;

        @JsonProperty("EndOfLife")
        private boolean endOfLife;

        @JsonProperty("Ncnr")
        private boolean ncnr;

        @JsonProperty("PrimaryVideoUrl")
        private String primaryVideoUrl;

        @JsonProperty("DateLastBuyChance")
        private String dateLastBuyChance;

        @JsonProperty("ManufacturerLeadWeeks")
        private String manufacturerLeadWeeks;

        @JsonProperty("ManufacturerPublicQuantity")
        private int manufacturerPublicQuantity;


        @JsonProperty("Classifications")
        private Classifications classifications;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Parameters {
        @JsonProperty("ParameterId")
        private Integer parameterId;
        @JsonProperty("ValueText")
        private String valueText;
    }


    @Data
    public static class Description {
        @JsonProperty("ProductDescription")
        private String productDescription;

        @JsonProperty("DetailedDescription")
        private String detailedDescription;
    }

    @Data
    public static class Manufacturer {
        @JsonProperty("Id")
        private int id;

        @JsonProperty("Name")
        private String name;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class ProductVariation {
        @JsonProperty("DigiKeyProductNumber")
        private String digiKeyProductNumber;

        @JsonProperty("PackageType")
        private PackageType packageType;

        @JsonProperty("StandardPricing")
        private List<Pricing> standardPricing;

        @JsonProperty("MyPricing")
        private List<Pricing> myPricing;

        @JsonProperty("MarketPlace")
        private boolean marketPlace;

        @JsonProperty("TariffActive")
        private boolean tariffActive;

        @JsonProperty("Supplier")
        private Manufacturer supplier; // Reuse Manufacturer as it has the same structure

        @JsonProperty("QuantityAvailableforPackageType")
        private int quantityAvailableForPackageType;

        @JsonProperty("MaxQuantityForDistribution")
        private long maxQuantityForDistribution;

        @JsonProperty("MinimumOrderQuantity")
        private int minimumOrderQuantity;

        @JsonProperty("StandardPackage")
        private int standardPackage;

        @JsonProperty("DigiReelFee")
        private double digiReelFee;
    }

    @Data
    public static class PackageType {
        @JsonProperty("Id")
        private int id;

        @JsonProperty("Name")
        private String name;
    }

    @Data
    public static class StatusEntity {
        @JsonProperty("Id")
        private int id;

        @JsonProperty("Status")
        private String status;
    }


    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Classifications{
        @JsonProperty("ExportControlClassNumber")
        private String ExportControlClassNumber;

    }

    @Data
    public static class Pricing {
        @JsonProperty("BreakQuantity")
        private int breakQuantity;

        @JsonProperty("UnitPrice")
        private double unitPrice;

        @JsonProperty("TotalPrice")
        double totalPrice;
    }
}
